<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>知心云直播后台</title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/login.min.css">
</head>
<body>
	<div class="login" id="dpLTE" v-cloak>
		<div class="message">知心云直播后台</div>
		<div id="darkbannerwrap"></div>
		<form method="post">
			<div v-if="error" class="alert alert-danger alert-dismissible">
				<h4 style="margin-bottom: 0px;font-size:13px;">
					<i class="fa fa-exclamation-triangle"></i> {{errorMsg}}
				</h4>
			</div>
			<input placeholder="用户名" v-model.trim="username" type="text">
			<hr class="hr15">
			<input placeholder="密码" v-model.trim="password" type="password">
			<hr class="hr15">
			<input value="登录" style="width: 100%;" type="button" @click="login">
			<hr class="hr20">
            <input value="微信登录" style="width: 100%;background-color: #00B83F" type="button" @click="weChatLogin">
			<!-- 帮助 <a onClick="alert('请联系管理员')">忘记密码</a> -->
		</form>
	</div>
	<div class="copyright">
		© sairobo by<a href="http://www.sairobo.com/" target="_blank"> sairobo</a>
	</div>
	<script src="libs/jquery.min.js"></script>
	<script src="libs/vue.min.js"></script>
	<script type="text/javascript">
		var vm = new Vue({
			el : '#dpLTE',
			data : {
				username : 'admin',
				password : '1',
				error : false,
				errorMsg : ''
			},
			beforeCreate : function() {
				if (self != top) {
					top.location.href = self.location.href;
				}
			},
			methods : {
				login : function(event) {
					if (vm.username == '') {
						vm.error = true;
						vm.errorMsg = '用户名为空';
						return false;
					}
					if (vm.password == '') {
						vm.error = true;
						vm.errorMsg = '密码为空';
						return false;
					}
					var data = "username=" + vm.username + "&password="
							+ vm.password;
					$.ajax({
						type : "POST",
						url : "sys/login",
						data : data,
						dataType : "json",
						success : function(result) {
							if (result.code == 0) {//登录成功
								localStorage.setItem("token", result.token);
								parent.location.href = 'index.html';
							} else {
								vm.error = true;
								vm.errorMsg = result.msg;
							}
						}
					});
				},
                weChatLogin:function(){
				    //正式-定位到微信登录二维码
                    window.open("https://open.weixin.qq.com/connect/qrconnect?" +
                        "appid=wxbfda601e592592c6" +
                        "&redirect_uri=http%3a%2f%2flive-pc.sairobo.cn%2fwechat%2fcallBack" +
                        "&response_type=code" +
                        "&scope=snsapi_login" +
                        "&state=STATE#wechat_redirect",
                        "_self");

                    //测试-定位到微信登录二维码
//                    window.open("https://open.weixin.qq.com/connect/qrconnect?" +
//                        "appid=wx1441847df14d59f2" +
//                        "&redirect_uri=http%3a%2f%2flive.sairobo.cn%2fwechat%2fcallBack" +
//                        "&response_type=code" +
//                        "&scope=snsapi_login" +
//                        "&state=STATE#wechat_redirect",
//                        "_self");
                }
			}
		});
	</script>
</body>
</html>
